package com.atnjupt.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Wizarder
 * @create 2022-03-22 20:45
 * 判断一个字符串是否全为中文字符
 * 中文字符所在的unicode编码范围为[\u4e00-\u9fa5]
 */
public class RegDemo {
    public static void main(String[] args) {
//        String context = "南京邮电大学";
        String context = "16567890129";
//        String regx = "^[\\u4e00-\\u9fa5]+$";
        String regx = "^1[3|4|5|6]\\d{9}$";//也可以写成^1[3|4|5|6]\\d{9}$
        //必须以13 14 15 16 开头的11位号码
        Pattern compile = Pattern.compile(regx);
        Matcher matcher = compile.matcher(context);
        if (matcher.find()) {
            System.out.println("满足匹配要求");
        } else {
            System.out.println("不满足匹配要求");
        }
    }
}
